<?php
// +----------------------------------------------------------------------
// | Buddy Framework 
// +----------------------------------------------------------------------
// | Copyright (c) 2011 http://buddy.woshimaijia.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: xinqiyang <xinqiyang@gmail.com>
// +----------------------------------------------------------------------

/**
 * Buddy Error Code class
 * if u use other code then modify this please
 * @author xinqiyang
 *
 */
class Error
{
	
	const USER_NAME_DUP			= 101;//用户重名
	const USER_NAME_MALFORM		= 102;//用户名格式错误，不允许包含特殊字符
	const USER_NAME_TOOSHORT	= 103;//用户名太短
	const USER_NAME_EMPTY		= 104;//用户名参数不能为空
	const USER_INFO_TOOLONG		= 105;//用户信息太长
	
	const USER_PWD_MALFORM		= 110;//密码不符合规范，必须是大小写字母加数字的组合
	const USER_PWD_LENERR		= 111;//密码长度错误
	const USER_APP_NOT_MATCH	= 112;//用户与应用不匹配
	const USER_PWD_COMPUTE_ERR	= 113;//计算密码出错
	const USER_PWD_SET_PIN		= 114;//需要用户设置pin码
	const USER_NO_RSA			= 115;//非TOKEN用户	
	
	const USER_TYPE_ERR			= 121;//用户类别错误
	const USER_EMAIL_MALFORM	= 122;//EMAIL格式错误
	const USER_EMAIL_EMPTY		= 123;//EMAIL格式错误
	const USER_INFO_ERR			= 124; //用户其他信息错误
	const USER_PWDRULE_ERR		= 125; //用户密码规则错误
	const USER_APPID_ERR		= 126; //用户appid错误
	const USER_ACCT_INSERR		= 127; //插入acct错误
	const USER_INFO_INSERR		= 128; //插入info错误
	
	
	//验证相关
	const LOGIN_INFO_NOTFULL	= 130; //登陆信息不完整
	const LOGIN_IMAGECODE_ERR	= 131; //验证码错误
	const LOGIN_UN_PWD_ERR		= 132; //用户名密码错误
	const LOGIN_USER_NOTFOUND	= 133; //用户不存在
	const LOGIN_FORCE_CHGPWD	= 134; //强制用户修改密码
	const LOGIN_NOT_ALLOW_ERR	= 135; //用户不允许登陆
	const LOGIN_APPID_SCOPE_ERR	= 136; //APP范围错误
	
	
	//改密码相关
	const CHG_NEW_OLD_EQUAL		= 141;//新旧密码不能一样
	const CHG_PWD_USED_RECENTL	= 142;//密码在近期使用过
	const CHG_PWD_ERROR			= 143;//修改密码错误
	const CHG_NEW_PWD_NOT_EQUAL	= 144;//两次输入新密码不一致
	const CHG_PWD_RSA_DENY		= 145;//RSA用户，不允许修改
	const CHG_PWD_UN_EQUAL		= 146;//密码与用户名相同
	
	//找回密码
	const USER_EMAIL_SEND_ERR	= 151;//email发送失败
	
	const USER_NAME_DUP_UC	= 161;//用户名与其他ucname重名
	const USER_NAME_DUP_BIZ	= 162;//用户名与其他bizname重名
	const USER_ACCT_EMAIL_DUP	= 171;//email在acct表发现重复
	
	const TOKEN_PIN_ERR			= 180;//PIN码格式错误
	const TOKEN_PC_ERR			= 181;//PASSCODE格式错误
	const TOKEN_SET_PIN_FAILED	= 182;//设置PIN码失败
	
	const UNKWON_ERROR			= 500; //未知错误
	const DB_ERROR				= 501; //数据库操作错误
	const PARAM_ERROR			= 502; //接口参数错误
	const NOT_FINISHED          = 503;//功能未实现

	const APP_LOGIN_ERROR = 600;
	
	const UTIL_COLUMN_MALFORM_ERROR		= 10001; //字段格式错误
	
	const UTIL_SENDMAIL_TPL_ERROR		= 10011; //发邮件模板错误
	const UTIL_SENDMAIL_UNKNOWN_ERROR	= 10012; //发邮件未知错误
	
	/**
	 * 消息函数
	 * @var array
	 */
	private static $_arrErrMap = array(
		self::USER_NAME_DUP => '输入的用户名已存在',
		self::USER_NAME_MALFORM => '用户名不允许包含特殊字符',
		self::USER_NAME_TOOSHORT => '用户名太短',
		self::USER_NAME_EMPTY => '用户名为空',
		self::USER_INFO_TOOLONG => '信息字段太长：',

		self::USER_PWD_MALFORM => '密码不符合规范，必须是大小写字母加数字的组合',
		self::USER_PWD_LENERR => '密码长度错误',
		self::USER_APP_NOT_MATCH=> '用户重名时登陆appid不符合',
		self::USER_PWD_COMPUTE_ERR=>'计算用户密码时错误',
		self::USER_PWD_SET_PIN => '需要设置pin码',
		self::USER_NO_RSA => '非TOKEN用户',

		self::USER_TYPE_ERR => '用户类别错误',
		self::USER_EMAIL_MALFORM => 'EMAIL格式错误',
		self::USER_EMAIL_EMPTY => '用户的email地址为空',
		self::USER_INFO_ERR => '用户信息错误',
		self::USER_PWDRULE_ERR => '用户密码规则错误',
		self::USER_APPID_ERR => '用户appid错误',
		self::USER_ACCT_INSERR => '插入acct错误',
		self::USER_INFO_INSERR => '插入info错误',

		self::LOGIN_INFO_NOTFULL => '登陆信息不完整',
		self::LOGIN_IMAGECODE_ERR=>'验证码错误',
		self::LOGIN_UN_PWD_ERR => '用户名或密码错误',
		self::LOGIN_USER_NOTFOUND => '找不到用户',
		self::LOGIN_FORCE_CHGPWD => '强制修改密码',
		self::LOGIN_NOT_ALLOW_ERR => '多次密码输入错误，账户被锁定',//'用户不允许登陆',
		self::LOGIN_APPID_SCOPE_ERR => 'app校验范围错误',
		
		self::CHG_NEW_OLD_EQUAL => '新旧密码不能一样',
		self::CHG_PWD_USED_RECENTL => '密码在近期使用过',
		self::CHG_PWD_ERROR =>'修改密码出错',
		self::CHG_NEW_PWD_NOT_EQUAL =>'两次输入新密码不一致',
		self::CHG_PWD_RSA_DENY=>'TOKEN不允许修改',
		self::CHG_PWD_UN_EQUAL=>'密码和用户名相同',
		
		self::USER_EMAIL_SEND_ERR =>'发送邮件失败',
		
		self::USER_NAME_DUP_UC => '用户名与ucname重名',
		self::USER_NAME_DUP_BIZ => '用户名与bizname重名',
		self::USER_ACCT_EMAIL_DUP => 'Email地址重复',
		
		self::TOKEN_PC_ERR=>'PASSCODE格式错误',
		self::TOKEN_PIN_ERR=>'PIN码格式错误',
		self::TOKEN_SET_PIN_FAILED=>'设置PIN码失败',
  
		self::UNKWON_ERROR => '未知错误',
		self::DB_ERROR=>'数据库操作错误',
		self::PARAM_ERROR=>'函数参数错误',
		self::NOT_FINISHED => '功能未实现',
		
		self::UTIL_COLUMN_MALFORM_ERROR => '字段格式错误',
		self::UTIL_SENDMAIL_TPL_ERROR => '发邮件模板错误',
		self::UTIL_SENDMAIL_UNKNOWN_ERROR => '发邮件未知错误',
	);
	
	/**
	 * get error msg
	 * @param string $intMsgId
	 */
	public static function getMsg($intMsgId) {
		return self::$_arrErrMap[$intMsgId];
	}
}
	